﻿namespace TestIndexChart
{
    using IndexChart.Graph;
    using System;
    using System.Drawing;
    using System.Windows.Forms;
    using ZedGraph;

    public partial class Form1 : Form
    {
        

        VolumeBarLine curve2;
        private IndexLine curve3;
        StockPointList datas = new StockPointList();
        BasePane pane1;
        BasePane pane2;

        

        

        public Form1()
        {
            InitializeComponent();
        }

        

        

        private void addVolumeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pane2 = kchart.AddPane("Volume", PaneType.Volume);
            curve2 = pane2.AddVolumeLine("");
            curve2.Datasource = new StockPtDataSource ( datas);
            this.kchart.Draw();
        }

        private void cToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pane1.BackGroundColor = pane1.BackGroundColor == Color.Black ? Color.White : Color.Black;
            this.kchart.Draw();
        }

        private void kchart_MouseMove(object sender, MouseEventArgs e)
        {
            Graphics aGraphics = this.CreateGraphics();
            Rectangle rect = new Rectangle(this.ClientRectangle.Location, this.ClientRectangle.Size);
            rect.Inflate(-1, -1);
              //  HatchBrush Hbrush = new HatchBrush(HatchStyle
        }

        private void tEST2ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //pane1.BackGroundColor = pane1.BackGroundColor == Color.Black ? Color.White : Color.Black;
        }

        private void tEST3ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.kchart.RawControl.IsSynchronizeXAxes = true;
            //this.kchart.RawControl.AxisChange();
            //this.kchart.SetDateChartLayout();
            this.kchart.Draw();
        }

        private void test4ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            pane1.RawPane.AddCurve("adsf",new double[]{1,4,5,55},new double[]{213,3,3,55},Color.Black);
            //pane1.RemoveCurve(curve);

            this.kchart.Draw();
        }

        private void test5ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.kchart.RawControl.IsSynchronizeXAxes = true;
            this.kchart.RawControl.IsSynchronizeXAxes = true;
            //this.kchart.RawControl.AxisChange();
            this.kchart.RawControl.Invalidate();
        }

        private void test6ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.kchart.Draw();
        }

        private void test7ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //var x = this.kchart.AddPane().AddTickNodeLine("");
            //x.Settlement_price =
        }

        private void test8ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var _curve = kchart.AddPane("asdf", PaneType.TickChange).AddTickChangedLine("");
            //var datas = DataGenerator.GenerateRedomSecondData(20100405, 1234, 2, 100);
            StockPtDataSource ds = new StockPtDataSource();
            _curve.Datasource = ds;

            kchart.Draw();
        }

        private void tESTToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /*
            datas = DataGenerator.GenerateDateData(20030411, 120);
            //pane1 = kchart.AddPane("candle",PaneType.Candle);
            curve = pane1.AddCandleCurve("test");
            curve.AddPoints(datas);

            this.toolStripStatusLabel1.Text = "finished";

            curve.RisingColor = Color.Red;
            curve.FallingColor = Color.Green;
            curve.RisingFilled = false;
            curve.FallingFilled = true;
            kchart.Draw();
            kchart.Refresh();*/
            var newdata =  DataGenerator.GenerateMinuteData(20101004, 10, 160);
            pane1 = kchart.AddPane("curve", PaneType.RealTime);
            //var cur1= pane1.addcu
        }

        private void upLineColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            curve3 = pane1.AddIndexLine("");

            curve3.Datasource = new StockPtDataSource(datas);
            this.kchart.Draw();

            //pane.BackGroundColor = Color.Black;
        }

        
    }
}